import 'dart:convert';
import 'package:x3_base_core/base_models/base_model_asT.dart';

/// 选择数据model
class BaseKeyValueModel {
  /// key 通常是 枚举值   value 汉字
  BaseKeyValueModel({this.key, this.value});

  factory BaseKeyValueModel.fromJson(Map<dynamic, dynamic> jsonRes) => jsonRes == null
      ? null
      : BaseKeyValueModel(
          key: asT<dynamic>(jsonRes['key']),
          value: asT<String>(jsonRes['value']),
        );

  dynamic key;
  String value;

  Map<String, dynamic> toJson() => <String, dynamic>{'key': key, 'value': value};

  Map<String, dynamic> toBaseJson(){
    return {'key': key, 'value': value};
  }

  @override
  String toString() {
    return json.encode(this);
  }
}
